package com.sale.system.service.impl;

import com.sale.common.core.utils.StringUtils;
import com.sale.common.redis.utils.RedisUtils;
import com.sale.common.satoken.utils.LoginHelper;
import com.sale.system.mapper.SysInventoryAccountingMapper;
import com.sale.system.service.ISysInventoryAccountingService;
import lombok.RequiredArgsConstructor;
import net.sf.jsqlparser.expression.StringValue;
import org.springframework.stereotype.Service;

/**
 * @Author: YSL
 * @Date: 2023-07-11 10:49:57
 * @Desc: 存货核算
 */
@RequiredArgsConstructor
@Service
public class SysInventoryAccountingServiceImpl implements ISysInventoryAccountingService {

    /**
     * 存货核算Mapper
     */
    private final SysInventoryAccountingMapper sysInventoryAccountingMapper;

    /**
     * 获取该账套下的成本核算方法(1、移动平均法，2、先进先出法)
     */
    @Override
    public int getCostAccountingMethod() {
        //获取当前登录的tenant_id
        String userIdStr = LoginHelper.getUserIdStr();
        String tenantId = RedisUtils.getCacheObject(userIdStr);
        return sysInventoryAccountingMapper.getCostAccountingMethod(tenantId);
    }
}
